package com.saascloud.core.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: liangxu
 * @Contact: one_dream@aliyun.com
 * @Date: 2022/4/25 14:28
 * @Version: 1.0
 * @Description:
 */
@Data
public class PageResult<T> implements Serializable {
    @ApiModelProperty(name = "返回集合")
    private List<T> list;
    @ApiModelProperty(name = "总条数")
    private Long total;

    public PageResult() {

    }

    public PageResult(List<T> list, Long total) {
        this.list = list;
        this.total = total;
    }

    public PageResult(Long total) {
        this.list = new ArrayList<>();
        this.total = total;
    }

    public static <T> PageResult<T> empty() {
        return new PageResult<>(0L);
    }

    public static <T> PageResult<T> empty(Long total) {
        return new PageResult<>(total);
    }
}
